package TreeNodePractice;

import javax.swing.tree.TreeNode;

public class MyClass {
    //检测是否有值为key的节点
    public TreeNode find(TreeNode root, int key){
        if(root == null)return null;
        if(root.val == key){
            return null;
        }
        TreeNode retleft = find(root.left,key);
        if(retleft != null){
            return retleft;
        }
        TreeNode retright =  find(root.right,key);
        if(retright != null){
            return retright;
        }
        return null;
    }
}
